<?php
class Todoprivate_ctl extends Ctl{
    function __construct(){
    }
    function main(array $xxfget) {
        $this::sessver();
        $type=!empty($_POST['type'])?$_POST['type']:false;
        $type=!empty($xxfget['type'])?$xxfget['type']:$type;
        if(!$type){
            //$navid=gconf('nav', 'toDoPrivate');
            $result=xdb::getInstance()->getarray('select * from todoprivate where uid='.$_SESSION['uid']);
            //$qxrow=xdb::getInstance()->getQxRow($navid, $_SESSION['id']);
            $this::show('todoprivate',compact('result'));
        }else{
            if($type=='ins'){
                $array=array();
                $array2=array();
                $content=$_POST['content'];
                $btime=$_POST['btime'];
                $level=$_POST['level'];
                $array['level']=$level;
                $array['content']=$content;
                $array['btime']=$btime;
                $array['uid']=$_SESSION['uid'];
                $array2['content']=$content;
                $array2['btime']=$btime;
                echo xdb::getInstance()->indb('todoprivate', $array, $array2);
            }elseif ($type=='upd'){
                $array=array();
                $array2=array();
                $id=$_POST['id'];
                $content=$_POST['content'];
                $btime=$_POST['btime'];
                $level=$_POST['level1'];
                $array['level']=$level;
                $array['content']=$content;
                $array['btime']=$btime;
                $array2['id']=$id;
                echo xdb::getInstance()->updb('todoprivate', $array, $array2);
            }elseif ($type=='del'){
                $array=array();
                $array['id']=$_POST['id'];
                echo xdb::getInstance()->deldb('todoprivate', $array);
            }elseif($type=='sub'){
                $tdid=$xxfget['tdid'];
                $result=xdb::getInstance()->getarray("select * from todosub where tdid=$tdid");
                $this->show("todosub",compact('result','tdid'));
            }elseif($type=="addsub"){
                $tdid=$_POST['tdid'];
                $content=$_POST['content'];
                echo xdb::getInstance()->indb("todosub", array('content'=>$content,'tdid'=>$tdid), array('id'=>0));
            }elseif($type=="fujian"){
                $tdsid=$xxfget['tdsid'];
                $tdid=$xxfget['tdid'];
                $result=xdb::getInstance()->getarray("select * from todofujian where tdsid=$tdsid");
                $this->show("todofujian",compact('result','tdsid','tdid'));
            }elseif($type=="addfujian"){
                $imgdata=$_POST['imgdata'];
                $tdsid=$_POST['tdsid'];
                $title=$_POST['title'];
                echo xdb::getInstance()->indb("todofujian",array('tdsid'=>$tdsid,'title'=>$title,'file'=>$imgdata),array('id'=>0));
            }elseif($type=="todoupd"){
                $tdsid=$xxfget['tdsid'];
                $result=xdb::getInstance()->getrow("select * from todosub where id=$tdsid");
                $this->show("todoupd",compact('result','tdsid'));
            }
        }
    }
}